/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.gov.ana.entities;

import java.io.Serializable;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author lucas.nunes
 */
@Entity
@Table(name = "QLTTB_ORGAO")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Orgao.findAll", query = "SELECT o FROM Orgao o"),
    @NamedQuery(name = "Orgao.findByOrgId", query = "SELECT o FROM Orgao o WHERE o.orgId = :orgId"),
    @NamedQuery(name = "Orgao.findByOrgNm", query = "SELECT o FROM Orgao o WHERE o.orgNm = :orgNm"),
    @NamedQuery(name = "Orgao.findByOrgSg", query = "SELECT o FROM Orgao o WHERE o.orgSg = :orgSg"),
    @NamedQuery(name = "Orgao.findByOrgTxEndereco", query = "SELECT o FROM Orgao o WHERE o.orgTxEndereco = :orgTxEndereco"),
    @NamedQuery(name = "Orgao.findByOrgNmRepresentante", query = "SELECT o FROM Orgao o WHERE o.orgNmRepresentante = :orgNmRepresentante"),
    @NamedQuery(name = "Orgao.findByOrgTxTelefone", query = "SELECT o FROM Orgao o WHERE o.orgTxTelefone = :orgTxTelefone"),
    @NamedQuery(name = "Orgao.findByOrgTxCep", query = "SELECT o FROM Orgao o WHERE o.orgTxCep = :orgTxCep"),
    @NamedQuery(name = "Orgao.findByOrgCargo", query = "SELECT o FROM Orgao o WHERE o.orgCargo = :orgCargo"),
    @NamedQuery(name = "Orgao.findByOrgCnpj", query = "SELECT o FROM Orgao o WHERE o.orgCnpj = :orgCnpj"),
    @NamedQuery(name = "Orgao.findByOrgEmail", query = "SELECT o FROM Orgao o WHERE o.orgEmail = :orgEmail"),
    @NamedQuery(name = "Orgao.findByOrgTxTelefone2", query = "SELECT o FROM Orgao o WHERE o.orgTxTelefone2 = :orgTxTelefone2"),
    @NamedQuery(name = "Orgao.findByOrgTxObservacao", query = "SELECT o FROM Orgao o WHERE o.orgTxObservacao = :orgTxObservacao"),
    @NamedQuery(name = "Orgao.findByOrgTxConsorcio", query = "SELECT o FROM Orgao o WHERE o.orgTxConsorcio = :orgTxConsorcio"),
    @NamedQuery(name = "Orgao.findByOrgStatus", query = "SELECT o FROM Orgao o WHERE o.orgStatus = :orgStatus")})
public class Orgao implements Serializable {
    private static final long serialVersionUID = 1L;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "ORG_ID")
    private BigDecimal orgId;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 104)
    @Column(name = "ORG_NM")
    private String orgNm;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 24)
    @Column(name = "ORG_SG")
    private String orgSg;
    @Size(max = 4000)
    @Column(name = "ORG_TX_ENDERECO")
    private String orgTxEndereco;
    @Size(max = 104)
    @Column(name = "ORG_NM_REPRESENTANTE")
    private String orgNmRepresentante;
    @Size(max = 104)
    @Column(name = "ORG_TX_TELEFONE")
    private String orgTxTelefone;
    @Size(max = 12)
    @Column(name = "ORG_TX_CEP")
    private String orgTxCep;
    @Size(max = 84)
    @Column(name = "ORG_CARGO")
    private String orgCargo;
    @Size(max = 29)
    @Column(name = "ORG_CNPJ")
    private String orgCnpj;
    @Size(max = 50)
    @Column(name = "ORG_EMAIL")
    private String orgEmail;
    @Size(max = 20)
    @Column(name = "ORG_TX_TELEFONE2")
    private String orgTxTelefone2;
    @Size(max = 4000)
    @Column(name = "ORG_TX_OBSERVACAO")
    private String orgTxObservacao;
    @Size(max = 500)
    @Column(name = "ORG_TX_CONSORCIO")
    private String orgTxConsorcio;
    @Column(name = "ORG_STATUS")
    private BigInteger orgStatus;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "oguOrgId")
    private List<OrgaoUnidade> orgaoUnidadeList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "oesOrgId")
    private List<OrgaoEstacao> orgaoEstacaoList;
    @JoinColumn(name = "ORG_STG_ID", referencedColumnName = "STG_ID")
    @ManyToOne
    private StatusOrgao orgStgId;
    @JoinColumn(name = "ORG_JUR_ID", referencedColumnName = "JUR_ID")
    @ManyToOne(optional = false)
    private Jurisdicao orgJurId;
    @JoinColumn(name = "ORG_UFD_CD", referencedColumnName = "UFD_CD")
    @ManyToOne
    private UnidadeFederacao orgUfdCd;
    @JoinColumn(name = "ORG_MUN_CD", referencedColumnName = "MUN_CD")
    @ManyToOne
    private Municipio orgMunCd;

    public Orgao() {
    }

    public Orgao(BigDecimal orgId) {
        this.orgId = orgId;
    }

    public Orgao(BigDecimal orgId, String orgNm, String orgSg) {
        this.orgId = orgId;
        this.orgNm = orgNm;
        this.orgSg = orgSg;
    }

    public BigDecimal getOrgId() {
        return orgId;
    }

    public void setOrgId(BigDecimal orgId) {
        this.orgId = orgId;
    }

    public String getOrgNm() {
        return orgNm;
    }

    public void setOrgNm(String orgNm) {
        this.orgNm = orgNm;
    }

    public String getOrgSg() {
        return orgSg;
    }

    public void setOrgSg(String orgSg) {
        this.orgSg = orgSg;
    }

    public String getOrgTxEndereco() {
        return orgTxEndereco;
    }

    public void setOrgTxEndereco(String orgTxEndereco) {
        this.orgTxEndereco = orgTxEndereco;
    }

    public String getOrgNmRepresentante() {
        return orgNmRepresentante;
    }

    public void setOrgNmRepresentante(String orgNmRepresentante) {
        this.orgNmRepresentante = orgNmRepresentante;
    }

    public String getOrgTxTelefone() {
        return orgTxTelefone;
    }

    public void setOrgTxTelefone(String orgTxTelefone) {
        this.orgTxTelefone = orgTxTelefone;
    }

    public String getOrgTxCep() {
        return orgTxCep;
    }

    public void setOrgTxCep(String orgTxCep) {
        this.orgTxCep = orgTxCep;
    }

    public String getOrgCargo() {
        return orgCargo;
    }

    public void setOrgCargo(String orgCargo) {
        this.orgCargo = orgCargo;
    }

    public String getOrgCnpj() {
        return orgCnpj;
    }

    public void setOrgCnpj(String orgCnpj) {
        this.orgCnpj = orgCnpj;
    }

    public String getOrgEmail() {
        return orgEmail;
    }

    public void setOrgEmail(String orgEmail) {
        this.orgEmail = orgEmail;
    }

    public String getOrgTxTelefone2() {
        return orgTxTelefone2;
    }

    public void setOrgTxTelefone2(String orgTxTelefone2) {
        this.orgTxTelefone2 = orgTxTelefone2;
    }

    public String getOrgTxObservacao() {
        return orgTxObservacao;
    }

    public void setOrgTxObservacao(String orgTxObservacao) {
        this.orgTxObservacao = orgTxObservacao;
    }

    public String getOrgTxConsorcio() {
        return orgTxConsorcio;
    }

    public void setOrgTxConsorcio(String orgTxConsorcio) {
        this.orgTxConsorcio = orgTxConsorcio;
    }

    public BigInteger getOrgStatus() {
        return orgStatus;
    }

    public void setOrgStatus(BigInteger orgStatus) {
        this.orgStatus = orgStatus;
    }

    @XmlTransient
    public List<OrgaoUnidade> getOrgaoUnidadeList() {
        return orgaoUnidadeList;
    }

    public void setOrgaoUnidadeList(List<OrgaoUnidade> orgaoUnidadeList) {
        this.orgaoUnidadeList = orgaoUnidadeList;
    }

    @XmlTransient
    public List<OrgaoEstacao> getOrgaoEstacaoList() {
        return orgaoEstacaoList;
    }

    public void setOrgaoEstacaoList(List<OrgaoEstacao> orgaoEstacaoList) {
        this.orgaoEstacaoList = orgaoEstacaoList;
    }

    public StatusOrgao getOrgStgId() {
        return orgStgId;
    }

    public void setOrgStgId(StatusOrgao orgStgId) {
        this.orgStgId = orgStgId;
    }

    public Jurisdicao getOrgJurId() {
        return orgJurId;
    }

    public void setOrgJurId(Jurisdicao orgJurId) {
        this.orgJurId = orgJurId;
    }

    public UnidadeFederacao getOrgUfdCd() {
        return orgUfdCd;
    }

    public void setOrgUfdCd(UnidadeFederacao orgUfdCd) {
        this.orgUfdCd = orgUfdCd;
    }

    public Municipio getOrgMunCd() {
        return orgMunCd;
    }

    public void setOrgMunCd(Municipio orgMunCd) {
        this.orgMunCd = orgMunCd;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (orgId != null ? orgId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Orgao)) {
            return false;
        }
        Orgao other = (Orgao) object;
        if ((this.orgId == null && other.orgId != null) || (this.orgId != null && !this.orgId.equals(other.orgId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "br.gov.ana.service.Orgao[ orgId=" + orgId + " ]";
    }
    
}
